﻿<%@ Control Language="C#" CodeFile="GoToPage.ascx.cs" Inherits="UserControls_GoToPage" %>
<link href="../css/styles.css" rel="stylesheet" type="text/css" />
<div>
    <asp:Panel ID="pnlPageArea" runat="server" DefaultButton="ibtPageGo">
        <div style="float: left">
            <span class="textUC" style="vertical-align: middle;">Page Size</span>
        </div>
        <div style="float: left; padding-left: 5px">
            <asp:DropDownList ID="ddlPageSize" runat="server" CssClass="GridDropDownL" Width="90px"
                Height="20px" AutoPostBack="True" OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
            </asp:DropDownList>
        </div>
        <div style="float: left; padding-left: 5px">
            <span class="text" style="width: 68px; vertical-align: middle;">Go To Page</span></div>
        <div style="float: left">
            <asp:TextBox runat="server" ID="txtPageNumber" Width="25px" CssClass="alignRightUC"
                onkeypress="return NonZeroNumericValues(this)" MaxLength="3" onblur="javascript:return ValidatePageNo(this);"></asp:TextBox></div>
        <div style="float: left; padding-left: 5px">
            <span class="text" style="width: 10px; vertical-align: middle">of</span></div>
        <div style="float: left; padding-left: 5px">
            <asp:Label runat="server" ID="lblCount" Width="19px" CssClass="text" Style="text-align: center;
                vertical-align: middle; font-weight: 100"></asp:Label></div>
        <div style="float: left; padding-left: 5px">
            <span class="text" style="width: 40px; vertical-align: middle;">Pages</span></div>
        <div style="float: left; padding-left: 5px">
            <asp:ImageButton runat="server" ID="ibtPageGo" CausesValidation="False" ImageUrl="~/images/go.jpg"
                OnClick="ibtPageGo_Click" /></div>
    </asp:Panel>
</div>

<script type="text/javascript">
    function NonZeroNumericValues(e) {

        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        else return true;

        var selection = document.selection.createRange();
        var selected_text = selection.text;

        if ((keycode == 46)) {
            return true;
        }
        //keycodes allowed but not in the beginning - 0
        if (keycode == 48 && ((e.value).length == 0 || selected_text != "")) {
            return false;
        }
        if (!(keycode >= 48 && keycode <= 57) && (keycode != 13)) {
            return false;
        }
        else return true;
    }

    function ValidatePageNo(txt) {

        var value = txt.value;
        if (txt.value != '') {
            if (parseFloat(txt.value) == 0) {
                txt.value = 1
                alert('Page no should not be Zero');
                txt.focus();
            }
        }
        //        else {
        //            txt.value = 1
        //            alert('Page no should not be empty');
        //            txt.focus();
        //        }
    }
</script>

